
<template>
    <vo-table ref="yuTable" :data="data.tableData" @getSelectionRows="getSelectionRows"  :fetch-data="fetchData">

      <template #tableForm>
          <tiny-form :model="data.formData" :rules="data.rules"  :inline="true"  style="height: 40px;" label-width="100px"  ref="formRef">
            <tiny-form-item label="字典查询" >
              <tiny-input v-model="data.info" placeholder="请输入表名"></tiny-input>
            </tiny-form-item>
            <tiny-form-item >
            <tiny-button  size="small"  type="info" @click="filterData"  ><vo-icon iconName="sousuo"/>搜索</tiny-button>
            </tiny-form-item>
        </tiny-form>
      </template>

      <template #leftBar>
        <tiny-button-group class="ml-4" size="small">
          <tiny-button type="primary" @click="addNotice">新增</tiny-button>
          <tiny-button type="primary" @click="delBatch">删除</tiny-button>
        </tiny-button-group>
      </template>
      <template v-slot:handleSlot="{row}">
        <tiny-button-group size="mini">
          <tiny-button  type="text" @click="editRow(row)" text="编辑" />
          <tiny-button  type="text" class="del_bts" @click="showDetail(row)" text="删除"/>
        </tiny-button-group>
      </template>
    </vo-table>
    <vo-dialog :data="data.editData.dialogConfig" v-model:isShow="data.editData.isShow">
      <NoticeEdit :data="data.editData.data"></NoticeEdit>
    </vo-dialog>
   
</template>
<script setup>
  import {reactive, onBeforeMount, ref, getCurrentInstance,onMounted} from 'vue';
  import NoticeEdit from './NoticeEdit.vue';
  let {proxy} = getCurrentInstance();
  const yuTable = ref(null);
  const data = reactive({
    info: '', //搜索信息
    tableData: {data: [], cols: [], tableArrts: {isPage: '1'}},
    editData: {data: {},isShow: false, dialogConfig: {title: '',height:'400px', width: '700px', lockScroll: false, showHeader: false}},
  });
  data.tableData.cols = [
    {type: 'index'},
    {type: 'selection'},
    {title: '公告标题', key: 'titleName', align: 'center', edit: false},
    {title: '公告类型', key: 'noticeType', align: 'center', edit: false},
    {title: '状态', key: 'status', align: 'center', edit: false},
    {title: '归属人', key: 'createUser', align: 'center', edit: false},
    {title: '创建时间', key: 'createDate', align: 'center', edit: false},
    {
      title: '操作',
      align: 'center',
      slot: 'handleSlot',
    },
  ];
  const addNotice = ()=>{
    data.editData.dialogConfig.title='新增通知';
    data.editData.data={status:'0'};
    data.editData.isShow=true;
  }
  const filterData = ()=> {
    yuTable.value.query();
  }
  const queryNotice = (page)=>{
    let params = {titleName:data.info};
    var page = {page:page};
    params = Object.assign({}, params,page);

    return proxy.$api.system.queryNotice(params)

  }
  const fetchData = ref({
    api: queryNotice
  })


</script>

<style lang="scss" scoped>
.del_bts{
  color: red !important;
}
</style>